home *** CD-ROM | disk | FTP | other *** search
- package javax.swing.text.html;
-
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.util.Hashtable;
- import java.util.Stack;
- import java.util.Vector;
- import javax.swing.event.UndoableEditEvent;
- import javax.swing.event.DocumentEvent.EventType;
- import javax.swing.text.AbstractDocument;
- import javax.swing.text.AttributeSet;
- import javax.swing.text.BadLocationException;
- import javax.swing.text.DefaultStyledDocument;
- import javax.swing.text.Element;
- import javax.swing.text.MutableAttributeSet;
- import javax.swing.text.SimpleAttributeSet;
- import javax.swing.text.StyleConstants;
- import javax.swing.text.html.HTML.Attribute;
- import javax.swing.text.html.HTML.Tag;
- import javax.swing.undo.CompoundEdit;
-
- public class HTMLDocument$HTMLReader extends HTMLEditorKit.ParserCallback {
- // $FF: synthetic field
- private final HTMLDocument this$0;
- int threshold;
- int offset;
- boolean inParagraph;
- boolean impliedP;
- boolean inPre;
- boolean inTextArea;
- TextAreaDocument textAreaDocument;
- boolean inTitle;
- boolean lastWasNewline;
- boolean emptyAnchor;
- boolean midInsert;
- boolean inBody;
- HTML.Tag insertTag;
- boolean insertInsertTag;
- boolean foundInsertTag;
- int popDepth;
- int pushDepth;
- Map lastMap;
- boolean inStyle;
- String defaultStyle;
- Vector styles;
- boolean inHead;
- boolean isStyleCSS;
- boolean emptyDocument;
- AttributeSet styleAttributes;
- Option option;
- protected Vector parseBuffer;
- protected MutableAttributeSet charAttr;
- Stack charAttrStack;
- Hashtable tagMap;
- int inBlock;
-
- public HTMLDocument$HTMLReader(HTMLDocument var1, int var2) {
- this(var1, var2, 0, 0, (HTML.Tag)null);
- }
-
- public HTMLDocument$HTMLReader(HTMLDocument var1, int var2, int var3, int var4, HTML.Tag var5) {
- this(var1, var2, var3, var4, var5, true);
- }
-
- HTMLDocument$HTMLReader(HTMLDocument var1, int var2, int var3, int var4, HTML.Tag var5, boolean var6) {
- this.this$0 = var1;
- this.inParagraph = false;
- this.impliedP = false;
- this.inPre = false;
- this.inTextArea = false;
- this.textAreaDocument = null;
- this.inTitle = false;
- this.lastWasNewline = true;
- this.inStyle = false;
- this.inHead = false;
- this.parseBuffer = new Vector();
- this.charAttr = new SimpleAttributeSet();
- this.charAttrStack = new Stack();
- this.inBlock = 0;
- this.emptyDocument = ((AbstractDocument)var1).getLength() == 0;
- this.isStyleCSS = "text/css".equals(var1.getDefaultStyleSheetType());
- this.offset = var2;
- this.threshold = var1.getTokenThreshold();
- this.tagMap = new Hashtable(57);
- new HTMLDocument.HTMLReader.TagAction(this);
- HTMLDocument.HTMLReader.BlockAction var8 = new HTMLDocument.HTMLReader.BlockAction(this);
- HTMLDocument.HTMLReader.ParagraphAction var9 = new HTMLDocument.HTMLReader.ParagraphAction(this);
- HTMLDocument.HTMLReader.CharacterAction var10 = new HTMLDocument.HTMLReader.CharacterAction(this);
- HTMLDocument.HTMLReader.SpecialAction var11 = new HTMLDocument.HTMLReader.SpecialAction(this);
- HTMLDocument.HTMLReader.FormAction var12 = new HTMLDocument.HTMLReader.FormAction(this);
- HTMLDocument.HTMLReader.HiddenAction var13 = new HTMLDocument.HTMLReader.HiddenAction(this);
- HTMLDocument.HTMLReader.ConvertAction var14 = new HTMLDocument.HTMLReader.ConvertAction(this);
- this.tagMap.put(Tag.A, new HTMLDocument.HTMLReader.AnchorAction(this));
- this.tagMap.put(Tag.ADDRESS, var10);
- this.tagMap.put(Tag.APPLET, var13);
- this.tagMap.put(Tag.AREA, new HTMLDocument.HTMLReader.AreaAction(this));
- this.tagMap.put(Tag.B, var14);
- this.tagMap.put(Tag.BASE, new HTMLDocument.HTMLReader.BaseAction(this));
- this.tagMap.put(Tag.BASEFONT, var10);
- this.tagMap.put(Tag.BIG, var10);
- this.tagMap.put(Tag.BLOCKQUOTE, var8);
- this.tagMap.put(Tag.BODY, var8);
- this.tagMap.put(Tag.BR, var11);
- this.tagMap.put(Tag.CAPTION, var8);
- this.tagMap.put(Tag.CENTER, var8);
- this.tagMap.put(Tag.CITE, var10);
- this.tagMap.put(Tag.CODE, var10);
- this.tagMap.put(Tag.DD, var8);
- this.tagMap.put(Tag.DFN, var10);
- this.tagMap.put(Tag.DIR, var8);
- this.tagMap.put(Tag.DIV, var8);
- this.tagMap.put(Tag.DL, var8);
- this.tagMap.put(Tag.DT, var9);
- this.tagMap.put(Tag.EM, var10);
- this.tagMap.put(Tag.FONT, var14);
- this.tagMap.put(Tag.FORM, var10);
- this.tagMap.put(Tag.FRAME, var11);
- this.tagMap.put(Tag.FRAMESET, var8);
- this.tagMap.put(Tag.H1, var9);
- this.tagMap.put(Tag.H2, var9);
- this.tagMap.put(Tag.H3, var9);
- this.tagMap.put(Tag.H4, var9);
- this.tagMap.put(Tag.H5, var9);
- this.tagMap.put(Tag.H6, var9);
- this.tagMap.put(Tag.HEAD, new HTMLDocument.HTMLReader.HeadAction(this));
- this.tagMap.put(Tag.HR, var11);
- this.tagMap.put(Tag.HTML, var8);
- this.tagMap.put(Tag.I, var14);
- this.tagMap.put(Tag.IMG, var11);
- this.tagMap.put(Tag.INPUT, var12);
- this.tagMap.put(Tag.ISINDEX, new HTMLDocument.HTMLReader.IsindexAction(this));
- this.tagMap.put(Tag.KBD, var10);
- this.tagMap.put(Tag.LI, var8);
- this.tagMap.put(Tag.LINK, new HTMLDocument.HTMLReader.LinkAction(this));
- this.tagMap.put(Tag.MAP, new HTMLDocument.HTMLReader.MapAction(this));
- this.tagMap.put(Tag.MENU, var8);
- this.tagMap.put(Tag.META, new HTMLDocument.HTMLReader.MetaAction(this));
- this.tagMap.put(Tag.NOFRAMES, var8);
- this.tagMap.put(Tag.OBJECT, var11);
- this.tagMap.put(Tag.OL, var8);
- this.tagMap.put(Tag.OPTION, var12);
- this.tagMap.put(Tag.P, var9);
- this.tagMap.put(Tag.PARAM, new HTMLDocument.HTMLReader.ObjectAction(this));
- this.tagMap.put(Tag.PRE, new HTMLDocument.HTMLReader.PreAction(this));
- this.tagMap.put(Tag.SAMP, var10);
- this.tagMap.put(Tag.SCRIPT, var13);
- this.tagMap.put(Tag.SELECT, var12);
- this.tagMap.put(Tag.SMALL, var10);
- this.tagMap.put(Tag.STRIKE, var14);
- this.tagMap.put(Tag.S, var10);
- this.tagMap.put(Tag.STRONG, var10);
- this.tagMap.put(Tag.STYLE, new HTMLDocument.HTMLReader.StyleAction(this));
- this.tagMap.put(Tag.SUB, var14);
- this.tagMap.put(Tag.SUP, var14);
- this.tagMap.put(Tag.TABLE, var8);
- this.tagMap.put(Tag.TD, var8);
- this.tagMap.put(Tag.TEXTAREA, var12);
- this.tagMap.put(Tag.TH, var8);
- this.tagMap.put(Tag.TITLE, new HTMLDocument.HTMLReader.TitleAction(this));
- this.tagMap.put(Tag.TR, var8);
- this.tagMap.put(Tag.TT, var10);
- this.tagMap.put(Tag.U, var14);
- this.tagMap.put(Tag.UL, var8);
- this.tagMap.put(Tag.VAR, var10);
- this.tagMap.put(HTMLDocument.EndOfLineTag, new HTMLDocument.HTMLReader.EndOfLineAction(this));
- ((AbstractDocument)var1).putProperty("AdditionalComments", (Object)null);
- if (var5 != null) {
- this.insertTag = var5;
- this.popDepth = var3;
- this.pushDepth = var4;
- this.insertInsertTag = var6;
- this.foundInsertTag = false;
- } else {
- this.foundInsertTag = true;
- }
-
- this.midInsert = !this.emptyDocument && var5 == null;
- if (this.midInsert) {
- this.generateEndsSpecsForMidInsert();
- }
-
- }
-
- // $FF: synthetic method
- static HTMLDocument access$0(HTMLDocument$HTMLReader var0) {
- return var0.this$0;
- }
-
- void addCSSRules(String var1) {
- StyleSheet var2 = this.this$0.getStyleSheet();
- var2.addRule(var1);
- }
-
- protected void addContent(char[] var1, int var2, int var3) {
- this.addContent(var1, var2, var3, true);
- }
-
- protected void addContent(char[] var1, int var2, int var3, boolean var4) {
- if (this.foundInsertTag) {
- if (var4 && !this.inParagraph && !this.inPre) {
- this.blockOpen(Tag.IMPLIED, new SimpleAttributeSet());
- this.inParagraph = true;
- this.impliedP = true;
- }
-
- this.emptyAnchor = false;
- this.charAttr.addAttribute(StyleConstants.NameAttribute, Tag.CONTENT);
- AttributeSet var5 = this.charAttr.copyAttributes();
- DefaultStyledDocument.ElementSpec var6 = new DefaultStyledDocument.ElementSpec(var5, (short)3, var1, var2, var3);
- this.parseBuffer.addElement(var6);
- if (this.parseBuffer.size() > this.threshold) {
- try {
- this.flushBuffer();
- } catch (BadLocationException var7) {
- }
- }
-
- if (var3 > 0) {
- this.lastWasNewline = var1[var2 + var3 - 1] == '\n';
- }
-
- }
- }
-
- protected void addSpecialElement(HTML.Tag var1, MutableAttributeSet var2) {
- if (var1 != Tag.FRAME && !this.inParagraph && !this.inPre) {
- this.blockOpen(Tag.IMPLIED, new SimpleAttributeSet());
- this.inParagraph = true;
- this.impliedP = true;
- }
-
- if (!this.foundInsertTag) {
- if (!this.isInsertTag(var1)) {
- return;
- }
-
- this.foundInsertTag();
- if (!this.insertInsertTag) {
- return;
- }
- }
-
- this.emptyAnchor = false;
- var2.addAttributes(this.charAttr);
- var2.addAttribute(StyleConstants.NameAttribute, var1);
- char[] var3 = new char[]{' '};
- DefaultStyledDocument.ElementSpec var4 = new DefaultStyledDocument.ElementSpec(var2.copyAttributes(), (short)3, var3, 0, 1);
- this.parseBuffer.addElement(var4);
- if (var1 == Tag.FRAME) {
- this.lastWasNewline = true;
- }
-
- }
-
- private void adjustEndElement() {
- int var1 = this.this$0.getLength();
- if (var1 != 0) {
- this.this$0.obtainLock();
-
- try {
- Element[] var4 = this.getPathTo(var1 - 1);
- if (var4.length > 2 && var4[1].getAttributes().getAttribute(StyleConstants.NameAttribute) == Tag.BODY && var4[1].getEndOffset() == var1) {
- String var5 = this.this$0.getText(var1 - 1, 1);
- Element[] var7 = new Element[0];
- Element[] var8 = new Element[1];
- int var9 = var4[0].getElementIndex(var1);
- var8[0] = var4[0].getElement(var9);
- ((AbstractDocument.BranchElement)var4[0]).replace(var9, 1, var7);
- AbstractDocument.ElementEdit var10 = new AbstractDocument.ElementEdit(var4[0], var9, var8, var7);
- AbstractDocument.DefaultDocumentEvent var6;
- if (var4.length == 3 && var4[2].getAttributes().getAttribute(StyleConstants.NameAttribute) == Tag.P && !var5.equals("\n")) {
- var9 = var4[2].getElementIndex(var1 - 1);
- AttributeSet var27 = var4[2].getElement(var9).getAttributes();
- if (var27.getAttributeCount() == 1 && var27.getAttribute(StyleConstants.NameAttribute) == Tag.CONTENT) {
- var7 = new Element[1];
- var8 = new Element[]{var4[2].getElement(var9)};
- int var29 = var8[0].getStartOffset();
- var7[0] = this.this$0.createLeafElement(var4[2], var27, var29, var1 + 1);
- ((AbstractDocument.BranchElement)var4[2]).replace(var9, 1, var7);
- HTMLDocument var31 = this.this$0;
- var31.getClass();
- var6 = new AbstractDocument.DefaultDocumentEvent(var31, var29, var1 - var29 + 1, EventType.CHANGE);
- var6.addEdit(new AbstractDocument.ElementEdit(var4[2], var9, var8, var7));
- } else {
- SimpleAttributeSet var28 = new SimpleAttributeSet();
- var28.addAttribute(StyleConstants.NameAttribute, Tag.CONTENT);
- var7 = new Element[]{this.this$0.createLeafElement(var4[2], var28, var1, var1 + 1)};
- ((AbstractDocument.BranchElement)var4[2]).replace(var9 + 1, 0, var7);
- HTMLDocument var30 = this.this$0;
- var30.getClass();
- var6 = new AbstractDocument.DefaultDocumentEvent(var30, var1, 1, EventType.CHANGE);
- var8 = new Element[0];
- var6.addEdit(new AbstractDocument.ElementEdit(var4[2], var9 + 1, var8, var7));
- }
- } else {
- SimpleAttributeSet var11 = new SimpleAttributeSet();
- var11.addAttribute(StyleConstants.NameAttribute, Tag.P);
- AbstractDocument.BranchElement var12 = (AbstractDocument.BranchElement)this.this$0.createBranchElement(var4[1], var11);
- var7 = new Element[]{var12};
- var8 = new Element[0];
- var9 = var4[1].getElementIndex(var1 - 1) + 1;
- ((AbstractDocument.BranchElement)var4[1]).replace(var9, 0, var7);
- HTMLDocument var10002 = this.this$0;
- var10002.getClass();
- var6 = new AbstractDocument.DefaultDocumentEvent(var10002, var1, 1, EventType.CHANGE);
- var6.addEdit(new AbstractDocument.ElementEdit(var4[1], var9, var8, var7));
- var7 = new Element[1];
- var11 = new SimpleAttributeSet();
- var11.addAttribute(StyleConstants.NameAttribute, Tag.CONTENT);
- var7[0] = this.this$0.createLeafElement(var12, var11, var1, var1 + 1);
- var12.replace(0, 0, var7);
- }
-
- var6.addEdit(var10);
- ((CompoundEdit)var6).end();
- this.this$0.fireChangedUpdate(var6);
- this.this$0.fireUndoableEditUpdate(new UndoableEditEvent(this, var6));
- }
- } catch (BadLocationException var15) {
- } finally {
- this.this$0.releaseLock();
- }
-
- }
- }
-
- protected void blockClose(HTML.Tag var1) {
- if (this.foundInsertTag) {
- if (!this.lastWasNewline) {
- this.addContent(HTMLDocument.access$0(), 0, 1, this.insertTag != null);
- this.lastWasNewline = true;
- }
-
- if (this.impliedP) {
- this.impliedP = false;
- this.inParagraph = false;
- this.blockClose(Tag.IMPLIED);
- }
-
- --this.inBlock;
- DefaultStyledDocument.ElementSpec var2 = this.parseBuffer.size() > 0 ? (DefaultStyledDocument.ElementSpec)this.parseBuffer.lastElement() : null;
- if (var2 != null && var2.getType() == 1) {
- char[] var3 = new char[]{' '};
- this.addContent(var3, 0, 1);
- }
-
- DefaultStyledDocument.ElementSpec var4 = new DefaultStyledDocument.ElementSpec((AttributeSet)null, (short)2);
- this.parseBuffer.addElement(var4);
- }
- }
-
- protected void blockOpen(HTML.Tag var1, MutableAttributeSet var2) {
- if (this.impliedP) {
- this.impliedP = false;
- this.inParagraph = false;
- this.blockClose(Tag.IMPLIED);
- }
-
- ++this.inBlock;
- if (!this.foundInsertTag) {
- if (!this.isInsertTag(var1)) {
- return;
- }
-
- this.foundInsertTag();
- if (!this.insertInsertTag) {
- return;
- }
- }
-
- this.lastWasNewline = false;
- var2.addAttribute(StyleConstants.NameAttribute, var1);
- DefaultStyledDocument.ElementSpec var3 = new DefaultStyledDocument.ElementSpec(var2.copyAttributes(), (short)1);
- this.parseBuffer.addElement(var3);
- }
-
- private int depthTo(int var1) {
- Element var2 = this.this$0.getDefaultRootElement();
-
- int var3;
- for(var3 = 0; !var2.isLeaf(); var2 = var2.getElement(var2.getElementIndex(var1))) {
- ++var3;
- }
-
- return var3;
- }
-
- public void flush() throws BadLocationException {
- this.flushBuffer();
- if (this.emptyDocument) {
- this.adjustEndElement();
- }
-
- }
-
- void flushBuffer() throws BadLocationException {
- int var1 = this.this$0.getLength();
- DefaultStyledDocument.ElementSpec[] var2 = new DefaultStyledDocument.ElementSpec[this.parseBuffer.size()];
- this.parseBuffer.copyInto(var2);
- if (var1 == 0 && this.insertTag == null) {
- this.this$0.create(var2);
- } else {
- this.this$0.insert(this.offset, var2);
- }
-
- this.parseBuffer.removeAllElements();
- this.offset += this.this$0.getLength() - var1;
- }
-
- private void foundInsertTag() {
- this.foundInsertTag = true;
- if (this.popDepth > 0 || this.pushDepth > 0) {
- try {
- if (this.offset == 0 || !this.this$0.getText(this.offset - 1, 1).equals("\n")) {
- SimpleAttributeSet var1 = null;
- boolean var2 = true;
- if (this.offset != 0) {
- Element var3 = this.this$0.getCharacterElement(this.offset - 1);
- AttributeSet var4 = var3.getAttributes();
- if (var4.isDefined(StyleConstants.ComposedTextAttribute)) {
- var2 = false;
- } else {
- Object var5 = var4.getAttribute(StyleConstants.NameAttribute);
- if (var5 instanceof HTML.Tag) {
- HTML.Tag var6 = (HTML.Tag)var5;
- if (var6 == Tag.IMG || var6 == Tag.HR || var6 == Tag.COMMENT || var6 instanceof HTML.UnknownTag) {
- var2 = false;
- }
- }
- }
- }
-
- if (!var2) {
- var1 = new SimpleAttributeSet();
- ((SimpleAttributeSet)var1).addAttribute(StyleConstants.NameAttribute, Tag.CONTENT);
- }
-
- DefaultStyledDocument.ElementSpec var10 = new DefaultStyledDocument.ElementSpec(var1, (short)3, HTMLDocument.access$0(), 0, HTMLDocument.access$0().length);
- if (var2) {
- var10.setDirection((short)4);
- }
-
- this.parseBuffer.addElement(var10);
- }
- } catch (BadLocationException var7) {
- }
- }
-
- for(int var8 = 0; var8 < this.popDepth; ++var8) {
- this.parseBuffer.addElement(new DefaultStyledDocument.ElementSpec((AttributeSet)null, (short)2));
- }
-
- for(int var9 = 0; var9 < this.pushDepth; ++var9) {
- DefaultStyledDocument.ElementSpec var11 = new DefaultStyledDocument.ElementSpec((AttributeSet)null, (short)1);
- var11.setDirection((short)5);
- this.parseBuffer.addElement(var11);
- }
-
- }
-
- private void generateEndsSpecsForMidInsert() {
- int var1 = this.heightToElementWithName(Tag.BODY, Math.max(0, this.offset - 1));
- boolean var2 = false;
- if (var1 == -1 && this.offset > 0) {
- var1 = this.heightToElementWithName(Tag.BODY, this.offset);
- if (var1 != -1) {
- var1 = this.depthTo(this.offset - 1) - 1;
- var2 = true;
- }
- }
-
- if (var1 == -1) {
- throw new RuntimeException("Must insert new content into body element-");
- } else {
- if (var1 != -1) {
- try {
- if (!var2 && this.offset > 0 && !this.this$0.getText(this.offset - 1, 1).equals("\n")) {
- SimpleAttributeSet var3 = new SimpleAttributeSet();
- var3.addAttribute(StyleConstants.NameAttribute, Tag.CONTENT);
- DefaultStyledDocument.ElementSpec var4 = new DefaultStyledDocument.ElementSpec(var3, (short)3, HTMLDocument.access$0(), 0, 1);
- this.parseBuffer.addElement(var4);
- }
- } catch (BadLocationException var5) {
- }
-
- while(var1-- > 0) {
- this.parseBuffer.addElement(new DefaultStyledDocument.ElementSpec((AttributeSet)null, (short)2));
- }
-
- if (var2) {
- DefaultStyledDocument.ElementSpec var6 = new DefaultStyledDocument.ElementSpec((AttributeSet)null, (short)1);
- var6.setDirection((short)5);
- this.parseBuffer.addElement(var6);
- }
- }
-
- }
- }
-
- private Element[] getPathTo(int var1) {
- Stack var2 = new Stack();
-
- for(Element var3 = this.this$0.getDefaultRootElement(); !var3.isLeaf(); var3 = var3.getElement(var3.getElementIndex(var1))) {
- var2.push(var3);
- }
-
- Element[] var5 = new Element[((Vector)var2).size()];
- ((Vector)var2).copyInto(var5);
- return var5;
- }
-
- public void handleComment(char[] var1, int var2) {
- if (this.inStyle) {
- if (this.styles != null) {
- this.styles.addElement(new String(var1));
- }
- } else if (this.this$0.getPreservesUnknownTags()) {
- if (this.inBlock == 0) {
- Object var4 = this.this$0.getProperty("AdditionalComments");
- if (var4 != null && !(var4 instanceof Vector)) {
- return;
- }
-
- if (var4 == null) {
- var4 = new Vector();
- this.this$0.putProperty("AdditionalComments", var4);
- }
-
- ((Vector)var4).addElement(new String(var1));
- return;
- }
-
- SimpleAttributeSet var3 = new SimpleAttributeSet();
- var3.addAttribute(Attribute.COMMENT, new String(var1));
- this.addSpecialElement(Tag.COMMENT, var3);
- }
-
- }
-
- public void handleEndTag(HTML.Tag var1, int var2) {
- if (!this.midInsert || this.inBody) {
- if (var1 == Tag.BODY) {
- this.inBody = false;
- if (this.midInsert) {
- --this.inBlock;
- }
- }
-
- HTMLDocument.HTMLReader.TagAction var3 = (HTMLDocument.HTMLReader.TagAction)this.tagMap.get(var1);
- if (var3 != null) {
- var3.end(var1);
- }
-
- }
- }
-
- public void handleSimpleTag(HTML.Tag var1, MutableAttributeSet var2, int var3) {
- if (!this.midInsert || this.inBody) {
- if (this.isStyleCSS && var2.isDefined(Attribute.STYLE)) {
- String var4 = (String)var2.getAttribute(Attribute.STYLE);
- var2.removeAttribute(Attribute.STYLE);
- this.styleAttributes = this.this$0.getStyleSheet().getDeclaration(var4);
- var2.addAttributes(this.styleAttributes);
- } else {
- this.styleAttributes = null;
- }
-
- HTMLDocument.HTMLReader.TagAction var5 = (HTMLDocument.HTMLReader.TagAction)this.tagMap.get(var1);
- if (var5 != null) {
- var5.start(var1, var2);
- var5.end(var1);
- } else if (this.this$0.getPreservesUnknownTags()) {
- this.addSpecialElement(var1, var2);
- }
-
- }
- }
-
- public void handleStartTag(HTML.Tag var1, MutableAttributeSet var2, int var3) {
- if (this.midInsert && !this.inBody) {
- if (var1 == Tag.BODY) {
- this.inBody = true;
- ++this.inBlock;
- }
-
- } else {
- if (!this.inBody && var1 == Tag.BODY) {
- this.inBody = true;
- }
-
- if (this.isStyleCSS && var2.isDefined(Attribute.STYLE)) {
- String var4 = (String)var2.getAttribute(Attribute.STYLE);
- var2.removeAttribute(Attribute.STYLE);
- this.styleAttributes = this.this$0.getStyleSheet().getDeclaration(var4);
- var2.addAttributes(this.styleAttributes);
- } else {
- this.styleAttributes = null;
- }
-
- HTMLDocument.HTMLReader.TagAction var5 = (HTMLDocument.HTMLReader.TagAction)this.tagMap.get(var1);
- if (var5 != null) {
- var5.start(var1, var2);
- }
-
- }
- }
-
- public void handleText(char[] var1, int var2) {
- if (!this.midInsert || this.inBody) {
- if (this.inTextArea) {
- this.textAreaContent(var1);
- } else if (this.inPre) {
- this.preContent(var1);
- } else if (this.inTitle) {
- this.this$0.putProperty("title", new String(var1));
- } else if (this.option != null) {
- this.option.setLabel(new String(var1));
- } else if (this.inStyle) {
- if (this.styles != null) {
- this.styles.addElement(new String(var1));
- }
- } else if (this.inBlock > 0 && var1.length >= 1) {
- this.addContent(var1, 0, var1.length);
- }
-
- }
- }
-
- private int heightToElementWithName(Object var1, int var2) {
- Element var3 = this.this$0.getCharacterElement(var2).getParentElement();
-
- int var4;
- for(var4 = 0; var3 != null && var3.getAttributes().getAttribute(StyleConstants.NameAttribute) != var1; var3 = var3.getParentElement()) {
- ++var4;
- }
-
- return var3 == null ? -1 : var4;
- }
-
- private boolean isInsertTag(HTML.Tag var1) {
- return this.insertTag == var1 || var1 == Tag.IMPLIED && var1 == Tag.P;
- }
-
- void linkCSSStyleSheet(String var1) {
- Object var2 = null;
-
- try {
- var5 = new URL(this.this$0.base, var1);
- } catch (MalformedURLException var4) {
- try {
- var5 = new URL(var1);
- } catch (MalformedURLException var3) {
- var5 = null;
- }
- }
-
- if (var5 != null) {
- this.this$0.getStyleSheet().importStyleSheet(var5);
- }
-
- }
-
- protected void popCharacterStyle() {
- if (!this.charAttrStack.empty()) {
- this.charAttr = (MutableAttributeSet)this.charAttrStack.peek();
- this.charAttrStack.pop();
- }
-
- }
-
- protected void preContent(char[] var1) {
- int var2 = 0;
-
- for(int var3 = 0; var3 < var1.length; ++var3) {
- if (var1[var3] == '\n') {
- this.addContent(var1, var2, var3 - var2 + 1);
- this.blockClose(Tag.IMPLIED);
- SimpleAttributeSet var4 = new SimpleAttributeSet();
- var4.addAttribute(javax.swing.text.html.CSS.Attribute.WHITE_SPACE, "pre");
- this.blockOpen(Tag.IMPLIED, var4);
- var2 = var3 + 1;
- }
- }
-
- if (var2 < var1.length) {
- this.addContent(var1, var2, var1.length - var2);
- }
-
- }
-
- protected void pushCharacterStyle() {
- this.charAttrStack.push(this.charAttr.copyAttributes());
- }
-
- protected void registerTag(HTML.Tag var1, HTMLDocument.HTMLReader.TagAction var2) {
- this.tagMap.put(var1, var2);
- }
-
- protected void textAreaContent(char[] var1) {
- try {
- this.textAreaDocument.insertString(this.textAreaDocument.getLength(), new String(var1), (AttributeSet)null);
- } catch (BadLocationException var2) {
- }
-
- }
- }
-